// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

var SexType = cc.Enum({
  未知: 0,
  男: 1,
  女: 2
});

cc.Class({
  extends: cc.Component,

  properties: {
    // foo: {
    //     // ATTRIBUTES:
    //     default: null,        // The default value will be used only when the component attaching
    //                           // to a node for the first time
    //     type: cc.SpriteFrame, // optional, default is typeof default
    //     serializable: true,   // optional, default is true
    // },
    // bar: {
    //     get () {
    //         return this._bar;
    //     },
    //     set (value) {
    //         this._bar = value;
    //     }
    // },
    // 性别  enum类型
    sex: {
      type: cc.Enum(SexType),
      default: SexType.未知
    },
    // 年龄 sex为男的时候显示
    age: {
      type: cc.Integer,
      default: 20,
      visible() {
        return this.sex === SexType.男
      }
    },
    // 滑动条
    score: {
      type: cc.Integer,
      default: 0,
      slide: true,
      min: 0,
      max: 159,
      step: 1,
      tooltip: '滚动条'
    },
    // 回调函数
    // 要想在属性面板绑定回调函数，需设置属性的type为cc.Component.EventHandler，设置默认值为空，并且在构造函数中初始化属性为cc.Component.EventHandler的实例。
    color: {
      type: cc.Component.EventHandler,
      default: null
    },
    mySprite: cc.Sprite,
    myAtlas: cc.SpriteAtlas,
  },

  // LIFE-CYCLE CALLBACKS:

  // onLoad() { 
  // },

  start() {
    this.color = new cc.Component.EventHandler()
  },
  changeImg() {
    this.mySprite.spriteFrame = this.myAtlas.getSpriteFrame('rabbit3')
  }
  // update (dt) {},
});
